# !/usr/bin/python3
# -*- coding: utf-8 -*-
# @Time    : 2021/9/30 10:08
# @Author  : zuodengbo
# @Email   : zuodb@amoydx.com
# @File    : config
# @Software: PyCharm
import os
from environs import Env

env = Env()
env.read_env()

ENV = env.str("SANIC_ENV", default="production")
DEBUG = ENV == "development"
username = env.str("DB_USERNAME")
password = env.str("DB_PASSWORD")
host = env.str("HOST")
port = env.str("DB_PORT")
db = env.str("DB_NAME")

db_config = {
    "connections": {
        "default": {
            "engine": "tortoise.backends.mysql",
            "credentials": {
                "host": host,
                "port": port,
                "user": username,
                "password": password,
                "database": db,
            }
        },
        "second": {
            "engine": "tortoise.backends.mysql",
            "credentials": {
                "host": host,
                "port": port,
                "user": username,
                "password": password,
                "database": "perm_test",
            }
        }
    },
    "apps": {
        "models": {
            "models": ["aerich.models", "user.models", "tasks.models"],
            # "models": ["aerich.models", "user.models", "tasks.models", "knowledge.models",
            #            "order.models", "product.models", "common.models"],
            "default_connection": "default"
        },
    }
}


class Config(object):
    """
    Basic config
    """
    # Application config
    SANIC_USE_TZ = False
    SANIC_TIMEZONE = "Asia/shanghai"
    BASE_DIR = os.path.dirname(os.path.dirname(__file__))
    DEBUG = True


class RedisConfig(object):
    """
    Redis config
    """
    host = "localhost"
    port = 6379
    db = 0
    password = None
    pool_size = 1


class EmailConfig(object):
    """
    Email config
    """
    server = "smtp.qq.com"
    port = 465
    user = "zooe.zuo@foxmail.com"
    password = "rtmukbhjembgcjgh"
    sender = "zooe.zuo@foxmail.com"
    receiver = "zuodb@amoydx.com, hrfnchiu@qq.com"
    subject = "Message From Borden System"


class SmsConfig(object):
    """
    手机短信发送配置
    """
    host = "106.ihuyi.com"
    sms_uri = "/webservice/sms.php?method=Submit"
    account = "C03688523"
    password = "d4a4050317a2af4dc5188199d40d7608"
